// import recast from 'recast';
const recast = require('recast');
const fs = require('fs');
const path = require("path");
// console.log(path.resolve(__dirname, './index.js'));

const mCode = fs.readFileSync(__dirname + '/code.js', { encoding: 'utf-8' });
const mAst = recast.parse(mCode);
// console.log(mAst); 
// console.log(recast.print(mAst).code);
recast.visit(mAst, {
    visitFunctionDeclaration({ node }) {

        if (node.id.name === 'cnm') {
            node.id.name = 'nihao'
        }
        console.log(node.id.name);
        return false;
    }
});
